package com.eastfair.enums;

import com.eastfair.annotation.base.BaseEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.stream.Stream;

/**
 * <p>
 * 语言环境枚举类
 *
 * </p>
 *
 * @author zjn
 * @date 2021-07-29
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "FileTypeEnum", description = "文件类型 #{PDF:PDF;JPG:JPG-枚举")
public enum FileTypeEnum implements BaseEnum {
    /**
     * PDF
     */
    PDF("PDF"),
    /**
     * DOC
     */
    DOC("DOC"),
    /**
     * DOCX
     */
    DOCX("DOCX"),
    /**
     * XLS
     */
    XLS("XLS"),
    /**
     * XLSX
     */
    XLSX("XLSX"),
    /**
     * PPT
     */
    PPT("PPT"),
    /**
     * PPTX
     */
    PPTX("PPTX"),
    /**
     * JPG
     */
    JPG("JPG"),
    /**
     * JEPG
     */
    JEPG("JEPG"),
    /**
     * PNG
     */
    PNG("PNG"),
    /**
     * GIF
     */
    GIF("GIF"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static FileTypeEnum match(String val, FileTypeEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static FileTypeEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(FileTypeEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "BLANK,PENDING,APPROVE,DISAPPROVE", example = "PENDING")
    public String getCode() {
        return this.name();
    }


}
